<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head th:replace="~{fragments/header :: header}">
</head>
<body>
<div sec:authorize="isAuthenticated()">
    <p>已有用户登录</p>
    <p>登录的用户为：<span sec:authentication="name"></span></p>
    <p>用户角色为：<span sec:authentication="principal.authorities"></span></p>
    <form action="/logout" th:action="@{/logout}" method="post">
        <input class="btn btn-outline-success" type="submit" value="退出">
    </form>
</div>
<div class="container blog-content-container" sec:authorize="isAnonymous()">

    <form  th:action="@{~/login}" method="post">
        <h2>登录失败，用户名或密码错误！！！</h2>

        <div class="form-group col-md-5">
            <label for="username" class="col-form-label">账号</label>
            <input type="text" class="form-control" id="username" name="username" maxlength="50" placeholder="请输入账号">
        </div>
        <div class="form-group col-md-5">
            <label for="password" class="col-form-label">密码</label>
            <input type="password" class="form-control" id="password" name="password" maxlength="30" placeholder="请输入密码" >
        </div>
        <div class="form-group col-md-5">
            <input type="checkbox" value="remember-me"> 记住我
        </div>
        <div class="form-group col-md-5">
            <button type="submit" class="btn btn-primary">登录</button>
        </div>

    </form>
</div> <!-- /container -->


<div th:replace="~{fragments/footer :: footer}">...</div>
</body>
</html>